# - Find the NVCtrlLib include file and library
#

SET(NVCtrlLib_INC_SEARCH_PATH
    /usr/X11R6/include
    /usr/local/include
    /usr/include/X11
    /usr/openwin/include
    /usr/openwin/share/include
    /opt/graphics/OpenGL/include
    /usr/include)

SET(NVCtrlLib_LIB_SEARCH_PATH
    /usr/X11R6/lib
    /usr/local/lib
    /usr/openwin/lib
    /usr/lib)


FIND_PATH(NVCtrlLib_INCLUDE_DIR NVCtrl/NVCtrlLib.h ${NVCtrlLib_INC_SEARCH_PATH})

FIND_LIBRARY(NVCtrlLib_LIBRARIES NAMES XNVCtrl PATH ${NVCtrlLib_LIB_SEARCH_PATH})

IF(NVCtrlLib_INCLUDE_DIR AND NVCtrlLib_LIBRARIES)
    SET(NVCtrlLib_FOUND TRUE)
ELSE(NVCtrlLib_INCLUDE_DIR AND NVCtrlLib_LIBRARIES)
    SET(NVCtrlLib_FOUND FALSE)
ENDIF(NVCtrlLib_INCLUDE_DIR AND NVCtrlLib_LIBRARIES)

IF(NVCtrlLib_FOUND)
    INCLUDE(CheckLibraryExists)

    SET(CMAKE_REQUIRED_LIBRARIES "-lX11 -lXext")

    CHECK_LIBRARY_EXISTS(${NVCtrlLib_LIBRARIES}
                         "XNVCTRLQueryAttribute"
                         ${NVCtrlLib_LIBRARIES}
                         NVCtrlLib_HAS_QUERY)

    IF(NVCtrlLib_HAS_QUERY)
        SET(XCD_USE_NVCTRL TRUE)
    ENDIF(NVCtrlLib_HAS_QUERY)
ENDIF(NVCtrlLib_FOUND)

CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/src/config.h.cmake
               ${CMAKE_BINARY_DIR}/src/config.h)

           #MARK_AS_ADVANCED(NVCtrlLib_INCLUDE_DIR NVCtrlLib_LIBRARIES)
